# -*- codeing = utf-8 -*-
# @Time : 2022/12/21 15:51
# @Author : 小马
# @File: plant_vs_zoomie_game_normal.py
# @Software : PyCharm
import pygame
import os
from Adc import Adc
from shooter import shoot
from Ap import Ap
from tank import tank
from Sun import Sun
from Bullet import Bullet
from Zombie import Zombie
from badmanmini import badmanmini

pygame.init()
#1680*720
backgd_size=(1200,600)
screen=pygame.display.set_mode(backgd_size)
pygame.display.set_caption('保卫花花之家')
bg_image_path= 'material/bg1.1.png'
bg_img_obj=pygame.image.load(bg_image_path).convert_alpha()

sunbank_image_path= 'material/counter2.jpeg'
sunbank_img_obj=pygame.image.load(sunbank_image_path).convert_alpha()


text='900'
sun_font=pygame.font.SysFont('arial',25)
sun_num_surface=sun_font.render(text,True,(0,0,0))
adc=Adc()
ap=Ap()
tank=tank()
shoot=shoot()
zombie=Zombie()
badmanmini=badmanmini()

sunList=[]
bulletList=[]

clock=pygame.time.Clock()



def init():
 running =True
 index=0
 while running:

    if index % 40==0:
        s=Sun(ap.rect)
        sunList.append(s)
    if index % 60==0:
        b=Bullet(adc.rect,backgd_size)
        bulletList.append(b)


    clock.tick(10)

    screen.blit(bg_img_obj,(0,0))
    screen.blit(sunbank_img_obj,(320,0))

    screen.blit(sun_num_surface,(350,70))
    screen.blit(adc.images[index%8],adc.rect)
    screen.blit(shoot.images[index%31],shoot.rect)
    screen.blit(ap.images[index % 26], ap.rect)
    screen.blit(tank.images[index % 31], tank.rect)
    if index<=250:
        left=index
    else:
        left=200

    screen.blit(zombie.images[index%5],zombie.rect)
    zombie.update()
    screen.blit(badmanmini.images[index%5],(1200-(left*5),200))

    for sun in sunList:
        screen.blit(sun.images[index % 1], sun.rect)
    for bullet in bulletList:
        screen.blit(bullet.image, bullet.rect)
        bullet.update()


    index+=1
    for event in pygame.event.get():
        if event.type==pygame.QUIT:
               running=False
    pygame.display.update()

if __name__=="__main__":
    init()
